test(setu-vlc): add unit tests for VectorClock and VLCSnapshot - #38
Open
Alicepoltora wants to merge 1 commit into
Open
test(setu-vlc): add unit tests for VectorClock and VLCSnapshot#38Alicepoltora wants to merge 1 commit into
Alicepoltora wants to merge 1 commit into
Conversation
The setu-vlc crate (vector logical clocks, the causality primitive used across consensus) shipped with a full public API but no tests, while sibling leaf crates carry 30-67. This adds 32 unit tests plus serde round-trip coverage for both VectorClock and VLCSnapshot: construction, increment/set/merge, happens-before / concurrency semantics (including empty-clock and new-node edge cases), transitivity, dynamic membership (remove/reset), GC (gc_zero_nodes, retain_active_nodes), and the receive() hybrid-logical-clock update rule. Adds serde_json as a dev-dependency for the serialization round-trip tests. No library code changed; behavior-preserving.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
setu-vlccrate (vector logical clocks — the causality primitive used across the consensus and networking layers) shipped with a complete public API but no tests, while sibling leaf crates carry 30–67 each (setu-merkle67,setu-keys35,setu-router-core32). This PR closes that gap.No library code is changed — the PR is behavior-preserving and only adds a
#[cfg(test)]module (matching the in-module convention used by the other crates).What's covered (32 unit tests + serde round-trips)
VectorClock: construction/defaults,
increment(auto-create + returned value),set/get,merge(element-wise max, node union, idempotence),happens_before(strict prefix, new-node-in-other, empty→nonempty, transitivity),is_concurrent(equal ≠ concurrent, divergent = concurrent), dynamic membership (remove_node,reset_node), GC (gc_zero_nodes,retain_active_nodes), serde round-trip.VLCSnapshot: construction,
increment, thereceive()hybrid-logical-clock update rule (logical_time = max(local, remote) + 1, merge, local bump), causal ordering across a send/receive, logical-time tiebreak when vector clocks are equal,is_concurrent,gc_inactive_nodes, serde round-trip.Notes
serde_json = "1.0"under[dev-dependencies]for the serialization round-trip tests (the types deriveSerialize/Deserializeto travel between nodes).cargo test -p setu-vlc→ 32 passed + 1 doc-test passed;cargo clippyclean; added code isrustfmt-clean.